﻿using System;
using System.Web;
using System.Data;
using System.Web.UI;
using System.Web.UI.WebControls;

using LTJ.Entity;
using LTJ.Common;
using LTJ.Config;
using LTJ.FrameWork;

namespace LTJ.WebPage.SystemManage.basedata
{
    /// <summary>
    /// 整柜港口信息调整
    /// </summary>
    public partial class fclbasedataset : AdminPage
    {
        protected int bdid = SASRequest.GetInt("bdid", 0);
        protected BaseDataInfo bdinfo = new BaseDataInfo();
        protected string opmode = SASRequest.GetString("opmode");

        protected void editauth_Click(object sender, EventArgs e)
        {
            string routeline = SASRequest.GetString("ajaxroutelinedatalist_value");
            string countrycode = SASRequest.GetString("ajaxcountrydata_value");
            int isstart = SASRequest.GetInt("isstart",0);

            if (routeline == "" || countrycode == "")
            {
                base.RegisterStartupScript("PAGETEMPLATE", "请输入完整的数据信息！");
                return;
            }

            bdinfo.code = "ports";
            bdinfo.tcode = _code.Text;
            bdinfo.name = _name.Text;
            bdinfo.ename = _ename.Text;
            bdinfo.expand1 = isstart.ToString();
            bdinfo.expand2 = routeline;
            bdinfo.expand3 = countrycode;

            if (opmode == "add")
            {
                if (BaseDatas.CreateBaseData(bdinfo) == -1)
                {
                    base.RegisterStartupScript("PAGETEMPLATE", "数据信息已存在！");
                    return;
                }
            }
            else
            {
                bdinfo.id = bdid;
                BaseDatas.UpdateBaseData(bdinfo);
            }

            base.RegisterStartupScript("PAGE", "parent.document.getElementById('reclick').click();parent.Lightview.hide();");
        }

        #region Web 窗体设计器生成的代码

        override protected void OnInit(EventArgs e)
        {
            InitializeComponent();
            base.OnInit(e);
        }

        private void InitializeComponent()
        {
            if (opmode == "edit")
            {
                bdinfo = BaseDatas.GetBaseDataByID(bdid);
                _code.Text = bdinfo.tcode;
                _name.Text = bdinfo.name;
                _ename.Text = bdinfo.ename;
            }

            editauth.Click += new EventHandler(editauth_Click);
        }

        #endregion
    }
}